<?php
include ($_SERVER['DOCUMENT_ROOT'].'/insp-modules/misc/config.php');
$conn = mysql_connect($host, $user, $password) or die(mysql_error());
mysql_select_db("eventfeedback");

session_start();
$login_json = $_SESSION['login_json'];
$login_info = json_decode($login_json, true);
$username = $login_info['username'];
$pwd = $login_info['password'];

$sql_login = "call Login('$username', '$pwd')";
$result_login = mysql_query($sql_login, $conn) or die(mysql_error());

if (mysql_num_rows($result_login)) {
	while ($row = mysql_fetch_assoc($result_login)) {
		$user_info_json = json_encode($row);
		$_SESSION['user_info_json'] = $user_info_json;
		// $_SESSION['isLogin'] = 1;
	}
	
	$sql_chapter = "call GetChapters()";
	$result_chapter = mysql_query("call GetChapters()", $conn) or die(mysql_error());
	// $chapter_name = array();
	// while ($row = mysql_fetch_assoc($result_chapter)) {
		// $name = $row['name'];
		// array_push($chapter_name, $name);
		// $chapter_name_json = json_encode($chapter_name);
		// $_SESSION['chapter_name_json'] = $chapter_name_json;
	// }
	// echo print_r($_SESSION);
	// $sql_program = "call GetEventDetails()";
	// $result_program = mysql_query($sql_program, $conn) or die(mysql_error());
	// $program_name = array();
	// while ($row = mysql_fetch_assoc($result_program)) {
		// $name = $row['name'];
		// array_push($program_name, $name);
		// $program_name_json = json_encode($program_name);
		// $_SESSION['program_name_json'] = $program_name_json;
	// }
	
	// header ('location: home.php');
}
?>